package condition;

import roborally.EnergyAmount;
import roborally.EnergyUnit;
import elements.Element;
import elements.IEnergyHolder;

/**
 * A class of binary basic conditions.
 * 
 * @version	3.0
 * @author 	Lies Tambeur 	r0264469	2Bcwsbbh
 * @author	Eline Vanrykel	r0264543	2Bcwselt
 *
 */
public class EnergyAtLeast extends BinaryBasicCondition {
	
	public EnergyAtLeast(EnergyAmount value) {
		super(value);
	}

	/**
	 * Returns true only if the element is allowed to contain a certain amount of energy
	 * and if that amount exceeds the value initialized in the constructor.
	 */
	@Override
	public boolean evaluate(Element element) {
		if(element instanceof IEnergyHolder){
			assert (!(value.isSmallerThan(new EnergyAmount())));
			return !( ((IEnergyHolder)element).getEnergy().isSmallerThan(value) );
		}
		else{
			return false;
		}
	}
	
	@Override
	public String toString(){
		return "( energy-at-least " +this.getValueToCheck().toEnergyUnit(EnergyUnit.WATTSECONDS).getAmount()+")";
	}
	
	@Override
	public boolean equals(Object object){
		if(object == null || this==null){
			return false;
		}
		return this.toString().equals(object.toString());
	}

}
